<?php



namespace App\Http\Requests\Company;


use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;

class AnthologyRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => 'required|max:120',
            'thumb' => 'required',
            'short_description' => 'required',
            'category_id' => 'required',
            'my_category_id' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'title.required' => __('请输入文集课程标题'),
            'title.max' => __('课程标题的长度不能超过:size个字符', ['size' => 120]),
            'thumb.required' => __('请上传课程封面'),
            'short_description.required' => __('请输入课程的简短介绍'),
            'description.required' => __('请输入课程详情介绍'),

        ];
    }

    public function filldata()
    {
        $user  = Auth::user();
        return [
            'user_id'=>(int)$user['app_id'],
            'company_id' =>(int)$user['login_company_id'],
            'category_id' => $this->input('category_id'),
            'my_category_id' => $this->input('my_category_id'),
            'chat_id'=>(int) $this->input('chat_id',0),
            'title' => $this->input('title'),
            'slug' => '',
            'thumb' => $this->input('thumb'),
            'charge' => $this->input('charge', 0),
            'short_description' => $this->input('short_description'),
            'description' => $this->input('description'),
            'render_desc' => $this->input('render_desc'),
            'seo_keywords' => (string)$this->input('seo_keywords', ''),
            'seo_description' => (string)$this->input('seo_description', ''),
            'is_show' => (int)$this->input('is_show', 1),
            'is_recommend' => (int)$this->input('is_recommend', 0),
            'is_free' => (int)$this->input('is_free'),
            'user_count' => (int)$this->input('user_count'),
            'papers' => (array)$this->input('papers', []),
            'faqs' => (array)$this->input('faqs', []),
            'target' => (array)$this->input('target',[]),
            'target_audience' => (array)$this->input('target_audience',[]),
            'advantage' => (array)$this->input('advantage',[]),
            'files' => (array)$this->input('files',[]),


        ];
    }
}
